import request from '@/utils/request'
import qs from 'qs'

export function query(params) {
  return request({
    url: 'api/shop/item?' + qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

export function add(data) {
  var param = {
    itemId: data.itemId,
    amount: data.itemAmount,
    memo: data.orderMemo
  }
  return request({
    url: 'api/shop/order',
    method: 'post',
    data: param
  })
}

export function cancel(ids) {
  return request({
    url: 'api/shop/order/cancel',
    method: 'post',
    data: ids
  })
}

export function pay(pcOrWeb, data) {
  return request({
    url: 'api/shop/order/pay/' + pcOrWeb,
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: 'api/shop/order',
    method: 'put',
    data
  })
}

export default { add, edit, cancel, pay, query }
